package com.spring.hot;

/**
 * @author Cizai
 * @since 2022/11/30 22:12
 **/
public class 正数反转 {

    public int reverse(int x) {

        int num = x;
        long sum = 0;
        if (x<0) num = -x;
        while (num > 0){
            sum =  (sum*10+num%10);
            num/=10;
        }
        return (int) (x<0 ? (int) -sum==-sum ? sum :0 :(int) sum==sum? sum :0);
    }
}
